// 
//  Copyright (C) 2009 Jacek Trubłajewicz
// 
//  This program is free software; you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation; either version 2 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// 

using System;
using System.Drawing;
using Mono.Unix;
using NLog;

namespace wxGadu
{
	
	
	public class TokenDialog : wx.Dialog
	{
		#region Id
		public enum Id
		{
		
		}
		#endregion
		
		#region controls
		private wx.Button okButton;
		private wx.StaticBitmap tokenSB;
		private wx.StaticText tokenValST;
		private wx.TextCtrl tokenValTC;
		#endregion
		
		#region data members
		private string tokenValue = string.Empty;
		private wx.Bitmap tokenBitmap;
		#endregion
		
		
		public TokenDialog(wx.Window parent, string title, wx.Bitmap tokenBmp):
			base(parent, title)
		{
			tokenBitmap = tokenBmp;
			
			DoControls();
			DoLayout();
			
			this.CenterOnParent();
			tokenValTC.SetFocus();
		}
		
		private void DoControls()
		{
			okButton = new wx.Button(this, wx.Window.wxID_OK, Catalog.GetString("OK"));
			okButton.SetDefault();
			tokenSB = new wx.StaticBitmap(this, tokenBitmap);
			tokenValST = new wx.StaticText(this, Catalog.GetString("Type image text: "));
			tokenValTC = new wx.TextCtrl(this, string.Empty);
			tokenValTC.ToolTip = Catalog.GetString("Type here text form the picture, capitalization does not matter");
		}
		
		private void DoLayout()
		{
			wx.BoxSizer topSizer = new wx.BoxSizer(wx.Orientation.wxVERTICAL);
			{
				wx.BoxSizer boxSizer = new wx.BoxSizer(wx.Orientation.wxVERTICAL);
				{
					wx.BoxSizer imageSizer = new wx.BoxSizer(wx.Orientation.wxHORIZONTAL);
					{
						imageSizer.Add(tokenSB, 0, wx.Alignment.wxALIGN_CENTER_VERTICAL|
						               wx.Direction.wxALL, 5);
						wx.BoxSizer textSizer = new wx.BoxSizer(wx.Orientation.wxVERTICAL);
						{
							textSizer.Add(tokenValST, 0, wx.Direction.wxBOTTOM, 5);
							textSizer.Add(tokenValTC, 0, wx.Stretch.wxEXPAND);
						}
						imageSizer.Add(textSizer, 0, wx.Direction.wxLEFT, 5);
					}
					boxSizer.Add(imageSizer, 0, 0);
					
					boxSizer.Add(20, 20, 0, 0, 0);
					boxSizer.Add(okButton, 0, wx.Alignment.wxALIGN_RIGHT);
				}
				topSizer.Add(boxSizer, 1, wx.Stretch.wxEXPAND|wx.Direction.wxALL, 5);
			}
			this.Sizer= topSizer;
			topSizer.SetSizeHints(this);
			topSizer.Fit(this);
		}
		
		public override bool TransferDataFromWindow()
		{
			tokenValue = tokenValTC.Value;
			
			return true;
		}
		
		public string TokenVal
		{
			get { return tokenValue; }
		}
	}
}
